using System;

namespace Scenario.WorkflowEngine.DataModel.WorkflowProcesses
{
	/// <summary>
	/// Summary description for Status.
	/// </summary>
	public class XMLStatus : bOS.XML.Data.XMLObject
	{
		public const string MAIN_NODE = "Status";

		private const string DATE_ATTRIBUTE		= "Date";
		
		private string sStatus;
		private string sDate;

		public XMLStatus()
		{
			this.Init();
		}

		public XMLStatus(System.Xml.XmlNode node)
		{
			Parse(node);
		}

		public string Status 
		{
			get { return sStatus; }
			set { sStatus = value; }
		}

		public string Date 
		{
			get { return sDate; }
			set { sDate = value; }
		}

		override public void Init()
		{
			sStatus= string.Empty;
			sDate= string.Empty;
		}

		/** Parsering method to fill the object **/
		override public void Parse(System.Xml.XmlNode node2Parse)
		{
			this.Init();

			System.Xml.XmlNode node;

			/** find the attributes situated on the root tag **/

			for ( int i=0; i<node2Parse.Attributes.Count; i++)
			{
				node= node2Parse.Attributes.Item(i);

				switch (node.Name)
				{
					case XMLStatus.DATE_ATTRIBUTE:
						sDate = node.InnerText;
						break;
				}
			}

			this.sStatus = node2Parse.InnerText;
		}

		/**Method to retive a node from object **/
		override public bOS.XML.XMLNode GetXMLNode()
		{
			bOS.XML.XMLNode xmlNode = new bOS.XML.XMLNode(XMLStatus.MAIN_NODE);

			xmlNode.SetValue (sStatus );

			xmlNode.AddAttribute ( new bOS.XML.XMLAttribute ( XMLStatus.DATE_ATTRIBUTE, sDate) );
			
			return xmlNode;
		}

	}
}
